﻿Namespace Facades

    Public NotInheritable Class MarkFacade

        Private brother As Infragistics.Windows.Chart.Mark

        Public Sub New(ByVal brother As Infragistics.Windows.Chart.Mark)
            MyBase.New()
            Me.brother = brother
        End Sub

        <EditableProperty()> _
        Public Property Stroke() As System.Windows.Media.Brush
            Get
                Return Me.brother.Stroke
            End Get
            Set(ByVal value As System.Windows.Media.Brush)
                Me.brother.Stroke = value
            End Set
        End Property

        <EditableProperty()> _
        Public Property Visible() As Boolean
            Get
                Return Me.brother.Visible
            End Get
            Set(ByVal value As Boolean)
                Me.brother.Visible = value
            End Set
        End Property

        'Classse Dashstyles existe avec des  modeles predefinis
        Public Property DashStyle() As System.Windows.Media.DashStyle
            Get
                Return Me.brother.DashStyle
            End Get
            Set(ByVal value As System.Windows.Media.DashStyle)
                Me.brother.DashStyle = value
            End Set
        End Property
      
        <EditableProperty()> _
        Public Property TickMarkSize() As Double
            Get
                Return Me.brother.TickMarkSize
            End Get
            Set(ByVal value As Double)
                Me.brother.TickMarkSize = value
            End Set
        End Property

        <EditableProperty()> _
        Public Property StrokeThickness() As Double
            Get
                Return Me.brother.StrokeThickness
            End Get
            Set(ByVal value As Double)
                Me.brother.StrokeThickness = value
            End Set
        End Property

        <EditableProperty()> _
        Public Property Unit() As Double
            Get
                Return Me.brother.Unit
            End Get
            Set(ByVal value As Double)
                Me.brother.Unit = value
            End Set
        End Property

        Public Function InternalToXElement() As XElement
            Dim x = <Mark
                        Stroke=<%= Stroke %>
                        Unit=<%= Unit %>
                        StrokeThickness=<%= StrokeThickness %>
                        TickMarkSize=<%= TickMarkSize %>
                        Visible=<%= Visible %>
                    />

            Return x
        End Function

        Public Sub InternalFromXElement(ByVal x As System.Xml.Linq.XElement)
            Dim cd = Function(s As String) Double.Parse(s, Globalization.CultureInfo.InvariantCulture)
            Dim cc = Function(s As String) If(String.IsNullOrEmpty(s), Nothing, (New Windows.Media.BrushConverter()).ConvertFromString(s))
            Dim ct = Function(s As String) (New Windows.ThicknessConverter()).ConvertFromInvariantString(s)


            Me.Stroke = cc(x.@Stroke)
            Me.Unit = cd(x.@Unit)
            Me.StrokeThickness = cd(x.@StrokeThickness)
            Me.Visible = x.@Visible
            'Me.DashStyle = x.@DashStyle
            Me.TickMarkSize = cd(x.@TickMarkSize)
        End Sub

    End Class
End Namespace


